import { useWatch } from '@/utils/AbstractStore';
import { Context, useContext } from 'react';

import { GlobalContext } from '@/store/GlobalStore';

const contexts = new Map([['GlobalContext', GlobalContext]]);

export default function useStore(contextName: string) {
	const store = useContext(contexts.get(contextName) as Context<any>);
	useWatch(store);

	return store;
}
